package com.example.myapplication;

/**
 * 禁用时间段模型
 */
public class BlockTimeSlot {
    private String id; // 唯一标识
    private int startHour;
    private int startMinute;
    private int endHour;
    private int endMinute;
    private boolean enabled; // 是否启用
    private RepeatType repeatType; // 重复类型
    private boolean skipHolidays; // 法定工作日（跳过节假日）

    public enum RepeatType {
        NO_REPEAT("不重复"),
        DAILY("每天"),
        WORKDAYS("法定工作日");

        private final String text;

        RepeatType(String text) {
            this.text = text;
        }

        public String getText() {
            return text;
        }
    }

    public BlockTimeSlot() {
        this.id = String.valueOf(System.currentTimeMillis());
        this.enabled = true;
        this.repeatType = RepeatType.DAILY;
        this.skipHolidays = false;
    }

    public BlockTimeSlot(String id, int startHour, int startMinute, int endHour, int endMinute,
                         boolean enabled, RepeatType repeatType, boolean skipHolidays) {
        this.id = id;
        this.startHour = startHour;
        this.startMinute = startMinute;
        this.endHour = endHour;
        this.endMinute = endMinute;
        this.enabled = enabled;
        this.repeatType = repeatType;
        this.skipHolidays = skipHolidays;
    }

    // Getters and Setters
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getStartHour() {
        return startHour;
    }

    public void setStartHour(int startHour) {
        this.startHour = startHour;
    }

    public int getStartMinute() {
        return startMinute;
    }

    public void setStartMinute(int startMinute) {
        this.startMinute = startMinute;
    }

    public int getEndHour() {
        return endHour;
    }

    public void setEndHour(int endHour) {
        this.endHour = endHour;
    }

    public int getEndMinute() {
        return endMinute;
    }

    public void setEndMinute(int endMinute) {
        this.endMinute = endMinute;
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public RepeatType getRepeatType() {
        return repeatType;
    }

    public void setRepeatType(RepeatType repeatType) {
        this.repeatType = repeatType;
    }

    public boolean isSkipHolidays() {
        return skipHolidays;
    }

    public void setSkipHolidays(boolean skipHolidays) {
        this.skipHolidays = skipHolidays;
    }

    public String getTimeRangeText() {
        return String.format("%02d:%02d - %02d:%02d", startHour, startMinute, endHour, endMinute);
    }

    public String getRepeatText() {
        if (repeatType == RepeatType.WORKDAYS && skipHolidays) {
            return "法定工作日（智能跳过节假日）";
        }
        return repeatType.getText();
    }
}

